package com.yanghang.service.impl;

import com.github.pagehelper.PageHelper;
import com.github.pagehelper.PageInfo;
import com.yanghang.dao.NewsDao;
import com.yanghang.entity.News;
import com.yanghang.service.NewsService;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;
import org.springframework.transaction.annotation.Transactional;

import java.util.List;

@Service
@Transactional
public class NewsServiceImpl implements NewsService {
    @Autowired
    private NewsDao nd;


    @Override
    @Transactional(readOnly = true)
    public List<News> selectAllNews() {
        return nd.selectAllNews();
    }

    @Override
    public PageInfo<News> selectByPage(int pageNum, int pageSize) {
        PageHelper.startPage(pageNum, pageSize);
        List<News> news = nd.selectList(null);
        return new PageInfo<>(news);
    }
}
